package com.example.demo.Class25_singleStack;

/**
 * @program: java_base
 * @description: 自己数组实现栈结构，速度快
 * @author: zhouhongtao
 * @happyCreateTime: 2022/03/06 12:58
 */
public class MyStack {


    Object[] arr;
    int index;

    public MyStack(int capacity) {
        arr = new Object[capacity];
        index =-1;
    }

    public void push(Object t){
        arr[++index] = t;
    }

    public Object pop(){
        if (index >= 0){
            return arr[index--];
        }
        return null;
    }

}
